<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h3>1</h3>
    <h3>1</h3>
    <h3>1</h3>
    <h3>1</h3>
</body>
</html>

<script>
// Array.from()方法用于将类数组转为真正的数组
/*
    温馨提示：常见的类数组有三类
        ①argumrnts
        ②元素集合
        ③类似数组的对象
*/
//类数组，为数组，只能使用数组的读取方式和length属性，不能使用数组方法：push()等等
//argumrnts
function arr(){
    console.log(arguments) //读取到 1，2，3，4，5
    console.log(arguments[0])
    console.log(arguments[1])
    console.log(arguments[2])
    console.log(arguments[3])
    console.log(arguments[4])
    var result = Array.from(arguments)
    result.push(6)
    console.log(result)
}
arr(1,2,3,4,5)


//元素集合
var h3 = document.getElementsByTagName("h3")
var h4 = document.querySelectorAll("h3")
console.log(h3)
console.log(Array.from(h3))
console.log(h4)
console.log(Array.from(h4))

//类似数组的对象（伪数组）
var user = {
    "0":'YANG',
    "1":22,
    "2":'男',
    length:3
}

console.log(user["1"])
console.log(user.length)
console.log(Array.from(user))

//Array.of()方法用于将一组值，转换为数组
console.log(Array.of(10,20,30,40,50))
console.log(Array(3))//返回一个由3个空元素组成的数组 [,,,]
</script>